#include <iostream>
using namespace std;
const int N=101;
int max(int a,int b);
int main()
{int n;int a[N][N],f[N][N],c=0;
 cin>>n;
 for(int i=1;i<=n;i++)
   { for (int j=1;j<=i;j++)
       cin>>a[i][j];
   }
   f[1][1]=0;
  for(int i=2;i<=n;i++)
   { for (int j=2;j<=i;j++)     
    f[i][j] =max(f[i-1][j-1],f[i-1][j])+a[i][j];
   }
   c=f[i][j];
   cout<<c<<endl;

 system ("pause");
 return 0;
}

int max(a,b)
{int a,b;
 if (a>=b)  return a;
 else return b;
}
 
